package com.matt.domain;

import com.matt.foundation.model.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;

/**
 * *******************************
 * description：请求日志
 * Created by Ron.
 * form com.matt
 * on 2017/9/26
 * *******************************
 */
@Entity
@Table(name = "action_log")
@Data
@EqualsAndHashCode(callSuper = true)
public class ActionLog extends Model {

    @Column(columnDefinition = " varchar(32)  COMMENT ' 对应员工id ' ")
    private String staffId;

    @Column(columnDefinition = " varchar(255)  COMMENT ' 请求的url ' ")
    private String actionUrl;

    @Column(columnDefinition = " text COMMENT ' 请求的参数 ' ")
    private String actionParams;

    @Column(columnDefinition = " varchar(255)  COMMENT ' 备用信息 ' ")
    private String extend;

    @Column(columnDefinition = " varchar(50)  COMMENT ' 请求的ip ' ")
    private String ip;

    @Column(columnDefinition = " datetime  COMMENT ' 创建时间 ' ")
    private Date created = new Date();

    public static ActionLog of(String staffId, String actionUrl, String actionParams, String ip){
        ActionLog log = new ActionLog();
        log.setStaffId(staffId);
        log.setActionUrl(actionUrl);
        log.setActionParams(actionParams);
        log.setIp(ip);
        return log;
    }
}
